package reflect;

import com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo4 {
    public static void main(String[] args) throws Exception {
//        Person person = new Person();
//        person.SayHello();

//        Class c=Class.forName("reflect.Person");
//
//        Object o = c.newInstance();
//        Method method = c.getMethod("SayHello");
//
//        method.invoke(o);
        Scanner scanner = new Scanner(System.in);
        System.out.println("input className:");
        String className = scanner.nextLine();
        System.out.println("input methodName:");
        String methodName=scanner.nextLine();
        Class c = Class.forName(className);
        Object o = c.newInstance();
        Method method = c.getMethod(methodName);
        method.invoke(o);
    }
}
